package com.onenine.app.activity;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import com.onenine.app.R;
import com.onenine.app.event.GameFilterEvent;
import com.onenine.app.utils.RoleResLoader;
import com.onenine.app.view.GameOptionView;
import com.onenine.base.base.BaseActivity;
import com.onenine.base.utils.StatusBarUtils;

import org.greenrobot.eventbus.EventBus;

/**
 * 游戏条件筛选
 */
public class GameFilterActivity extends BaseActivity {

    private static GameFilterEvent sGameFilterEvent;
    private GameOptionView mGameOptionView;
    private Button mBtnConfirm;

    public static void launchActivity(Context context) {
        Intent intent = new Intent(context, GameFilterActivity.class);
        context.startActivity(intent);
    }

    private void setWindowTheme() {
        StatusBarUtils.setTransparent(this);
        Window window = getWindow();
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.width = WindowManager.LayoutParams.MATCH_PARENT;
        wl.height = WindowManager.LayoutParams.MATCH_PARENT;
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_game_filter;
    }

    @Override
    protected void initViews() {
//        setWindowTheme();
        super.initViews();
        mGameOptionView = findViewById(R.id.gov_option);
        mBtnConfirm = findViewById(R.id.btn_confirm);
        mBtnConfirm.setBackgroundResource(RoleResLoader
                .getRoleDrawableResourceId(RoleResLoader.DynamicResName.THEME_GRADIENT_CORNER_BG));
    }

    @Override
    protected void initListeners() {
        super.initListeners();
        mBtnConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GameFilterEvent event = new GameFilterEvent();
                event.gameCategory = mGameOptionView.getGameCategory();
                event.betAmountPair = mGameOptionView.getGameBetAmountPair();
                event.modePair = mGameOptionView.getGameModePair();
                event.limitPair = mGameOptionView.getGamePlayerLimitPair();
                EventBus.getDefault().post(event);
                finish();
            }
        });
        findViewById(R.id.btn_quit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
//
    }

    @Override
    protected void initData() {
        super.initData();
        if (sGameFilterEvent != null) {
            mGameOptionView.setGameFilterEvent(sGameFilterEvent);
        }
    }

    public static void setGameFilterEvent(GameFilterEvent sGameFilterEvent) {
        GameFilterActivity.sGameFilterEvent = sGameFilterEvent;
    }

}
